<?php
	include_once 'isLogin.php';
	
	include_once 'alipay/alipay.config.php';

	require_once("alipay/lib/alipay_submit.class.php");
	
	$order_id = $_GET['id'];
	
	if(!$batch_no){
		$batch_no = date('Ymd').rand(1000,9999);
	}
	
	$batch_num = '1';
	
	$orderc = new order($pagec);
	
	$where = ' AND o.id = "' . $order_id . '"';
	$row = $orderc->orderInfo($where , 'o.*');
	
	$refund = $orderc->refundInfo($order_id , '*' , 'order_id');
	$row['refund_info'] = $refund;
	
	$smarty->assign('row',$row);

	$alipay_code = $row['alipay_code'];			//交易号

	$detail_data = $alipay_code . '^' . $refund['refund_cash'] . '^' . $refund['reason'];

	$param = array(
			"service" => trim($alipay_config['service']),
			"partner" => trim($alipay_config['partner']),
			"notify_url"	=> trim($alipay_config['notify_url']),
			"seller_user_id"	=> trim($alipay_config['seller_user_id']),
			"refund_date"	=> trim($alipay_config['refund_date']),
			"batch_no"	=> $batch_no,
			"batch_num"	=> $batch_num,
			"detail_data"	=> $detail_data,
			"_input_charset"	=> trim(strtolower($alipay_config['input_charset']))
	);

	$orderc->refundUpdate(array('refund_code' => $batch_no), 'id ="'.$refund['id'].'"');
	
	//建立请求
	$alipaySubmit = new AlipaySubmit($alipay_config);
	$html_text = $alipaySubmit->buildRequestForm($param,"get", "确认");
	echo $html_text;
	
?>